package com.bistu.openlab.uofspreadsheet.util;

import java.io.File;

/*
 *@author xiaoguang.gao@oracle.com
 *@version 2013-5-11 
 */
public class PrepareTmpDir {

	/**
	 * create tmp file to store xml files
	 */
	public static void IniticalTmp(){
		File tmpDir = new File("tmp");
		ClearTmp();
		tmpDir.mkdirs();
	}
	/**
	 * delete tmp directory
	 */
	public static void ClearTmp(){
		File tmpDir = new File("tmp");
		if(tmpDir.exists()){
			remove(tmpDir);//delete tmp directory			
		}
	}
	/**
	 * 
	 * @param file
	 */
	private static void remove(File file){
		if(file.isDirectory()){
			File[] files = file.listFiles();
			if(files!=null){
				for(File f : files){
					remove(f);
				}
			}
			file.delete();//delete directory
		}else if(file.isFile()){
			file.delete();//delete file
		}
		
	}
}
